/***************************************************************************

-------------------
    begin                : 
    copyright            : kuzkok
    email                : kuzkok at gmail.com

***************************************************************************
*                                                                         *
*   This program is free software; you can redistribute it and/or modify  *
*   it under the terms of the GNU General Public License as published by  *
*   the Free Software Foundation; either version 2 of the License, or     *
*   (at your option) any later version.                                   *
*   
*   Данная программа является свободным программным обеспечением;         *
*   Вы можете распространять ее и/или модифицировать в соответствии с     *
*   GNU General Public License опубликованной Фондом свободного           *
*   программного обеспечения; используемая версия лицензии - 2 или        *
*   (по вашему выбору) любая более поздняя                                *
***************************************************************************/

#include "onlinefeature.h"

OnlineFeature::OnlineFeature(QString theTableName) :
        ObjectArchive(theTableName)
{
}

OnlineFeature::OnlineFeature(QUuid theEventID, QString theTableName) :
        ObjectArchive(theEventID, theTableName)
{
    if(mObjectState)
    {
        mStationSeriesEventID = QUuid(mSelectQuery->value(mSelectQuery->record().indexOf("stationserieseventid")).toString());
        mCLValidityTolerance = mSelectQuery->value(mSelectQuery->record().indexOf("clvaliditytolerance")).toDouble();
        mCLEditResponse = mSelectQuery->value(mSelectQuery->record().indexOf("cleditresponse")).toString();
    }
}


void OnlineFeature::buildInsertStatement()
{
    ObjectArchive::buildInsertStatement();
    mInsertStatementFields += ", stationserieseventid"
                             ", clvaliditytolerance"
                             ", cleditresponse";
    mInsertStatementValues += ", :stationserieseventid"
                             ", :clvaliditytolerance"
                             ", :cleditresponse";
}

void OnlineFeature::buildUpdateStatement()
{
    ObjectArchive::buildUpdateStatement();
    mUpdateStatement += ",stationserieseventid = :stationserieseventid"
                       ",clvaliditytolerance = :clvaliditytolerance"
                       ",cleditresponse = :cleditresponse";
}

void OnlineFeature::bindQueryValues(QSqlQuery &query)
{
    ObjectArchive::bindQueryValues(query);
    query.bindValue(":stationserieseventid", UuidToVariant(mStationSeriesEventID));
    query.bindValue(":clvaliditytolerance", mCLValidityTolerance);
    query.bindValue(":cleditresponse", mCLEditResponse);
}
